package com.monitor.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.monitor.entity.ErpClaims;

/**
 * <p>
 * 理赔单表 Mapper 接口
 * </p>
 *
 * @author LX
 * @since 2018-09-25
 */
public interface ErpClaimsMapper extends BaseMapper<ErpClaims> {
	//质量理赔列表查询
	@Select("SELECT * FROM erp_claims as c WHERE type=#{type} and  (customer_name in(${names}) or claims_unit in(${names})) order by id desc")
	public List<ErpClaims> selectByCustName(@Param("type")int type,@Param("names")String names);
	
	//质量理赔添加页面生产编号查询按钮
	@Select("SELECT sr.id as srId,ro.id as roId,ro.sale_repair_sheet_id,sr.materiel_brand,sr.materiel_Specifications,sr.materiel_model,sr.materiel_production_id,ro.sale_repair_date,sr.materiel_price,sr.materiel_out_to FROM erp_sale_repair_sale as sr LEFT JOIN erp_sale_repair_order as ro ON sr.order_id=ro.id where sr.materiel_production_id!='' and ro.customer_id=#{custId} and ro.sale_repair_sheet_id like #{word}")
	public List<Map<String, Object>> selectSaleAndOrderList(@Param("custId")int custId,@Param("word")String word);
	
	//质量理赔添加页面生产编号查询按钮弹出框后选择钮
	@Select("SELECT sr.id as srId,ro.id as roId,ro.sale_repair_sheet_id,sr.materiel_name,sr.materiel_brand,sr.materiel_Specifications,sr.materiel_model,sr.materiel_production_id,ro.sale_repair_date,sr.materiel_price,sr.materiel_out_to,ro.sale_repair_mileage,ro.customer_name,sr.materiel_unit FROM erp_sale_repair_sale as sr LEFT JOIN erp_sale_repair_order as ro ON sr.order_id=ro.id  where sr.materiel_production_id!='' and sr.id=#{srId}")
	public Map<String, Object> selectDateilBySrsId(@Param("srId")int srId);
	
	//物料索赔添加页面生产编号查询按钮
	@Select("SELECT sr.id as srId,ro.id as roId,ro.sale_repair_sheet_id,sr.materiel_brand,sr.materiel_Specifications,sr.materiel_model,sr.materiel_production_id,ro.sale_repair_date,sr.materiel_price,sr.materiel_out_to FROM erp_sale_repair_sale as sr LEFT JOIN erp_sale_repair_order as ro ON sr.order_id=ro.id where sr.materiel_production_id!='' and ro.car_plate in(${carPlates}) and ro.sale_repair_sheet_id like #{word}")
	public List<Map<String, Object>> selectSaleAndOrderListByCarPlate(@Param("carPlates")String carPlates,@Param("word")String word);
}
